package com.pmt.feedplayer.ui

import androidx.compose.foundation.layout.*
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.pmt.feedplayer.controller.PlayerController
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

/**
 * iOS平台的VideoPlayer实现
 */
actual @Composable
fun VideoPlayer(controller: PlayerController, modifier: Modifier) {
    // 控制UI显示状态
    val showControls = remember { mutableStateOf(true) }
    val coroutineScope = rememberCoroutineScope()
    
    // 显示控制UI的函数
    fun show() {
        showControls.value = true
        // 3秒后自动隐藏
        coroutineScope.launch {
            delay(3000)
            showControls.value = false
        }
    }
    
    Box(modifier = modifier
        .fillMaxSize()
        .clickable { show() }
    ) {
        // 平台播放器视图
        PlatformPlayerView(controller, Modifier.fillMaxSize())
        
        // 简单的控制文本
        if (showControls.value) {
            Column(modifier = Modifier.fillMaxSize()) {
                // 底部控制栏
                Column(
                    modifier = Modifier
                        .fillMaxWidth()
                        .padding(16.dp)
                        .align(Alignment.BottomStart)
                ) {
                    Text(
                        text = "Video Player Controls",
                        color = Color.White,
                        fontSize = 12.sp
                    )
                }
            }
        }
    }
}